package com.qf.lanzhou.shop.admin.service.impl;

import com.qf.lanzhou.shop.admin.dao.ClassficationMapper;
import com.qf.lanzhou.shop.admin.dao.GoodsMapper;
import com.qf.lanzhou.shop.admin.service.GoodsManageService;
import com.qf.lanzhou.shop.pojo.entity.*;
import com.qf.lanzhou.shop.pojo.qo.GoodsClassficationQo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author LEON-HE
 */
@Service
public class GoodsManageServiceImpl implements GoodsManageService {
    @Autowired
    private ClassficationMapper classficationMapper;
    @Autowired
    private GoodsMapper goodsMapper;

    @Override
    public GoodsClassficationQo getAllClassfication() {
        GoodsClassficationQo goodsClassficationQo = new GoodsClassficationQo();
        goodsClassficationQo.setCategoryList(classficationMapper.selectCategoryAll());
        goodsClassficationQo.setFunctionList(classficationMapper.selectFunctionAll());
        goodsClassficationQo.setAppearanceList(classficationMapper.selectAppearanceAll());
        goodsClassficationQo.setControlTypeList(classficationMapper.selectControlTypeAll());
        goodsClassficationQo.setMaterialList(classficationMapper.selectMaterialAll());
        return goodsClassficationQo;
    }

    @Override
    public int insertGoods(Goods goods) {
        int i = goodsMapper.insertGoods(goods);
        return 1;
    }

    @Override
    public List<Goods> selectAllGoods() {
        List<Goods> goodsList = goodsMapper.selectAllGoods();
        return goodsList;
    }

    @Override
    public int updateEventStatus(int status, int goodId) {
        int result = goodsMapper.updateEventStatus(status, goodId);
        return result;
    }

    @Override
    public int goodsPutOn(Long id) {
        int result = goodsMapper.goodsPutOn(id);
        return result;
    }

    @Override
    public int offTheGoods(Long id) {
        int result = goodsMapper.offTheGoods(id);
        return result;
    }

    @Override
    public int deleteGoods(Long id) {
        int result = goodsMapper.deleteGoods(id);
        return result;
    }

    @Override
    public int undateGoodsMsg(Goods goods) {
        int result = goodsMapper.undateGoodsMsg(goods);
        return result;
    }

    @Override
    public int updateCurrentPrice(int currentPrice, int goodId) {
        int result = goodsMapper.updateCurrentPrice(currentPrice, goodId);
        return result;
    }
}
